//
//  MangerBook.m
//  03_HomeWork
//
//  Created by dllo on 16/7/6.
//  Copyright © 2016年 LST. All rights reserved.
//

#import "MangerBook.h"

@implementation MangerBook

- (instancetype) initWithBookArr:(NSMutableArray *) bookArr {
    self = [super init];
    if (self) {
        _allBook = bookArr;
    }
    return self;
}
+ (instancetype) bookManagerWithBookArr:(NSMutableArray *) bookArr {
    return [[self alloc] initWithBookArr:bookArr];
}
- (void)addBook:(Book *)book {
    [self.allBook addObject:book];
}
- (void)deleBook:(Book *)book {
    [self.allBook removeObject:book];
}
- (void)display {
    NSMutableArray *bookName = [NSMutableArray array];
    for (int i = 0; i < self.allBook.count; i++) {
        Book *books = [self.allBook objectAtIndex:i];
        [bookName addObject:books];
    }
    NSLog(@"%@",bookName);
}
- (void)searchBook:(Book *)book {
    for (Book *bookArray in self.allBook) {
        if ([bookArray.bookName isEqualToString:@"红楼梦"]) {
            bookArray.bookPrice = 25;
        }
        NSLog(@"书名:%@价格:%ld", bookArray.bookName, bookArray.bookPrice);
    }

}

@end
